package com.basker.pisces.domain.value;

import java.util.Date;

import com.basker.pisces.utils.DateUtils;

public class DateTimeValue implements IValueObject {

    public final static DateTimeValue NULL_DATE = new DateTimeValue(null, null) {
        @Override
        public Object getDataValue() {
            return null;
        }

        @Override
        public String getPresentValue() {
            return "";
        }
    };

    private Date date;
    private String format;

    public DateTimeValue(Date date, String format) {
        this.date = date;
        this.format = format;
    }

    @Override
    public Object getDataValue() {
        return date;
    }

    @Override
    public String getPresentValue() {
        return date != null ? DateUtils.format(date, format) : "";
    }

    @Override
    public boolean isEmpty() {
        return date == null;
    }

}
